package com.csi.controller;

import com.csi.service.SchedulingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Component
public class SchedulingController {

    @Autowired
    private SchedulingService schedulingService;

    @Scheduled(fixedDelay = 172800000)
    @Transactional
    //定时任务1，删除审核未通过的酒店
    public void task1(){
        List<String> cancelHotelIds = schedulingService.findHotelStatus();
        int deleted = schedulingService.deleteHotel(cancelHotelIds);
    }
    @Scheduled(fixedDelay = 172800000)
    @Transactional
    //定时任务2，删除审核未通过的酒店加盟
    public void task2(){
        List<String> cancelFacilityIds = schedulingService.findFacilityStatus();
        int deleted = schedulingService.deleteFacility(cancelFacilityIds);
    }

    @Scheduled(fixedDelay = 172800000)
    @Transactional
    //定时任务3，删除审核未通过的酒店加盟
    public void task3(){
        List<String> cancelRoomTypeIds = schedulingService.findRoomTypeStatus();
        int deleted = schedulingService.deleteRoomType(cancelRoomTypeIds);
    }


}
